<template>
	<view class="studyIndex">
		<view class="box" >
			<view class="studyIndexImg studyImg1"></view>
			<view class="middle">
				<view class="title">学费</view>
				<view class="text">专业费用一共1000元</view>
			</view>
			<view class="rightNotice">
				<radio value="1000" checked="true" class="radioStyle"/>
			</view>
		</view>
		<view>
			<button type="default" form-type="submit" class="loginBtn" @click="details">立即缴费</button>
		</view>
	</view>
</template>

<script>
	const {study} = require('../../utils/api.js')
	const {insertAmount} = require('../../utils/admin.js')
	export default {
		data() {
			return {
				im:["studyImg1","studyImg2","studyImg3"],
				study:[],
				detailsData:{
					name:'',
					num:'',
					company:'南昌大学财务处',
					address:'南昌大学软件楼655',
					mode:'微信',
					amount:0
				}
			}
		},
		created() {
			this.getStudy();
			let stu = uni.getStorageSync('stu');
			this.detailsData.name = stu.name;
			//随机生成缴费码
			let m = 5;
			m = m > 13 ? 13 : m;
			var num = new Date().getTime();
			this.detailsData.num = num.toString().substring(13 - m);
			uni.setStorageSync('num',this.detailsData.num);
		},
		methods:{
			getStudy(){
				study().then(data=>{
					this.study = data.data;
				})
			},
			details(){
				this.study.forEach(item=>{
					if(item.ck === "true"){
						this.detailsData.amount += parseInt(item.amount);
					}
				})
				insertAmount(this.detailsData).then(data=>{
					if(data.code === 200){
						console.log("成功")
					}
				})
				uni.navigateTo({
					url: 'details'
				});
			}
		}
	}
</script>

<style scoped src="../../static/css/msg.css"></style>
<style scoped src="../../static/css/grade.css"></style>
<style scoped>
	.uni-list-cell {
	    justify-content: flex-start
	}
</style>
